<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 250px;
            height: 80px;
            background-color: red;
            margin: auto;
            margin-top: 200px;
        }
       
        #btn:hover{
            cursor: pointer;
            transition: 0.5s;
            transform: scale(1.2);
            background-color: pink;
            color: blue;
            font-size: x-large;
        }
    </style>
</head>
<body>
    <div>
        <input type="button" value="开关灯" id="btn" style="width: 250px; height: 80px;" >
    </div>
       
        <script>

            let btn=document.getElementById('btn');
            var flag=true;
            btn.onclick=function(){
                if(flag){
                    document.body.style.backgroundColor='black'
                    flag=false;
                }else{
                    document.body.style.backgroundColor='white'
                    flag=true;
                }

            }

            if(confirm('确定要离开我吗？'))
            {
                location.assign('https://gitee.com/')
            }

        </script>

</body>
</html>